package com.nxj.config;

import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Set;

public class MySpringServletContainerInitializer implements ServletContainerInitializer {

    // MyWebApplicationInitializer 不会扫到这边
    // 这边不会扫到自己定义的   MyWebApplicationInitializer  好奇怪
    public void onStartup(Set<Class<?>> set, ServletContext servletContext) throws ServletException {
        if (set != null) {
            for (Class<?> aClass : set) {
                try {
                    ((WebApplicationInitializer) aClass.newInstance()).onStartup(servletContext);
                } catch (InstantiationException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
